﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Game.Utils;
using Game.Facade;
using System.Text;
using Game.Kernel;
using Game.Entity.NativeWeb;
using Game.Entity.Accounts;
using Game.Entity.Treasure;

namespace Game.Web.RoomCard
{
    public partial class GoldBuyRecord : UCPageBase
    {
        protected int RoomCardCount = 0;              //房卡数

        #region 继承属性

        protected override bool IsAuthenticatedUser
        {
            get
            {
                return true;
            }
        }

        #endregion

        protected void Page_Load(object sender, EventArgs e)
        {
            if(!IsPostBack)
            {
                BindDataList();
            }
        }

        protected void anpPage_PageChanged(object sender, EventArgs e)
        {
            BindDataList();
        }

        protected void BindDataList()
        {
            //绑定数据
            int userID = Fetch.GetUserCookie().UserID;
            string where = " WHERE TypeID = 4 AND SourceUserID = " + userID;
            PagerSet pagerSet = FacadeManage.aideRecordFacade.GetRoomCardRecord(where, PageIndex, anpPage.PageSize);
            anpPage.RecordCount = pagerSet.RecordCount;
            if(pagerSet.PageSet.Tables[0].Rows.Count > 0)
            {
                rptData.DataSource = pagerSet.PageSet;
                rptData.DataBind();
                litNoData.Visible = false;
            }
            else
            {
                litNoData.Visible = true;
            }

            //已有房卡数
            UserRoomCard card = FacadeManage.aideTreasureFacade.GetUserRoomCard(userID);
            RoomCardCount = card != null ? card.RoomCard : 0;
        }

        /// <summary>
        /// 增加页面标题
        /// </summary>
        protected override void AddHeaderTitle()
        {
            AddMetaTitle("游戏币购买房卡记录 - " + ApplicationSettings.Get("title"));
            AddMetaKeywords(ApplicationSettings.Get("keywords"));
            AddMetaDescription(ApplicationSettings.Get("description"));
        }
    }
}